﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
                   assembly="DDDSample.DomainModel.Operations" 
                   namespace="DDDSample.DomainModel.Operations.Cargo">
  <class name="Cargo" table="Cargo">
    <id type="Guid">
      <column name="Id" />
      <generator class="guid"></generator>
    </id>
    <many-to-one name="OrderingCustomer" class="DDDSample.DomainModel.Potential.Customer.Customer" cascade="none"/>
    <component name="TrackingId" update="false" class="TrackingId">
      <property name="_idString" column="TrackingId" not-null="true" access="field"/>
    </component>
    <component name="Delivery">
      <property name="_misdirected" column="IsMisdirected" not-null="true" access="field"/>
      <property name="_eta" column="Eta" not-null="false" access="field"/>
      <property name="_calculatedAt" column="CalculatedAt" not-null="true" access="field"/>
      <property name="_isUnloadedAtDestination" column="UnloadedAtDest" not-null="true" access="field"/>
      <property name="_routingStatus" column="RoutingStatus" not-null="true" access="field"/>
      <property name="_transportStatus" column="TransportStatus" not-null="true" access="field"/>              
      <many-to-one name="_lastKnownLocation" column="LastKnownLocationId" not-null="false" cascade="none" access="field"/>      
      <component name="_lastEvent" update="true" access="field">
        <property name="_eventType" access="field" column="LastEventType"/>
        <many-to-one name="_location" column="LastEventLocation" class="DDDSample.DomainModel.Potential.Location.Location" access="field"/>
        <property name="_registrationDate" access="field" column="LastEventRegistrationDate"/>
        <property name="_completionDate" access="field" column="LastEventCompletionDate"/>
      </component>
      <component name="_nextExpectedActivity" update="true" access="field">
        <many-to-one name="_location" column="NextExpectedLocationId" cascade="none" access="field"/>
        <property name="_eventType" column="NextExpectedHandlingEventType" access="field"/>        
      </component>
    </component>
    <component name="RouteSpecification" class="RouteSpecification">
      <many-to-one name="_origin" column="SpecOriginId" class="DDDSample.DomainModel.Potential.Location.Location" access="field" not-null="true"/>
      <many-to-one name="_destination" column="SpecDestinationId" class="DDDSample.DomainModel.Potential.Location.Location" access="field" not-null="true"/>      
      <property name="_arrivalDeadline" column="SpecArrivalDeadline" not-null="true" access="field"/>
    </component>
    <component name="Itinerary" class="Itinerary">         
      <list name="_legs" lazy="true" cascade="all" access="field" table="Leg">
        <key column="CargoId"/>
        <index column="LegIndex"/>
        <composite-element class="Leg">
          <many-to-one name="_voyage" column="VoyageId" class="DDDSample.DomainModel.Potential.Voyage.Voyage" access="field"/>
          <many-to-one name="_loadLocation" column="LoadLocation" class="DDDSample.DomainModel.Potential.Location.Location" access="field"/>
          <many-to-one name="_unloadLocation" column="UnloadLocation" class="DDDSample.DomainModel.Potential.Location.Location" access="field"/>
          <property name="_loadDate" column="LoadDate" access="field"/>
          <property name="_unloadDate" column="UnloadDate" access="field"/>
        </composite-element>        
      </list>
    </component>
  </class>
</hibernate-mapping>